package com.test.mchelepesa.util_rice.helper_rice;

import android.provider.Settings;
import android.text.TextUtils;

import com.test.mchelepesa.activity_fragment_rice.base_rice.BaseApplication_rice;
import com.test.mchelepesa.constant_rice.Constant_rice;
import com.test.mchelepesa.util_rice.StringUtil_rice;

import org.jetbrains.annotations.NotNull;

public class DeviceHelper_rice {

    private static class InnerDeviceHelper {
        private static final DeviceHelper_rice instance = new DeviceHelper_rice();
    }

    public static DeviceHelper_rice getInstance() {
        return InnerDeviceHelper.instance;
    }

    @NotNull
    public static String getPackageName() {
        try {
            String pckName = BaseApplication_rice.gApplication_rice().getPackageName();
            if (TextUtils.isEmpty(pckName)) {
                pckName = Constant_rice.NAME;
            }
            return pckName;
        }catch (Exception e){
            StringUtil_rice.printException(e);
            return "";
        }
    }

    @NotNull
    public String getAndroidID() {
        String androidID = Settings.System.getString(BaseApplication_rice.gApplication_rice().getContentResolver(), Settings.Secure.ANDROID_ID);
        if (TextUtils.isEmpty(androidID)) {
            return System.currentTimeMillis() + "";
        }
        if (androidID.contains("00000000")) {
            return System.currentTimeMillis() + "";
        }
        return androidID;
    }

}
